public class HHZ {
    public static void main(String[] args) {
        Node head = new Node();
        head.data = "0";
        Node cNode = null;
        Node pNode = null;
        for (int i = 1; i < 15; i ++) {
            cNode = new Node();
            cNode.data = String.valueOf(i);
            if (head.next == null) {
                head.next = cNode;
            }
            if (pNode != null) {
                pNode.next = cNode;
            }
            cNode.next = null;
            pNode = cNode;
        }
        Node tmp = head;
        while (tmp != null) {
            System.out.print(tmp.data + "->");
            tmp = tmp.next;
        }
        System.out.println("");
        head = reverse(head);
        tmp = head;
        while (tmp != null) {
            System.out.print(tmp.data + "->");
            tmp = tmp.next;
        }
    }

    static class Node {
        String data;
        Node next;
    }

    /**
     * 下一个节点指向上一个节点
     * @param head
     * @return
     */
    static Node reverse(Node head) {
        Node pNode = null;
        Node nextNode = null;
        while (head != null){
            nextNode = head.next;
            head.next = pNode;
            pNode = head;
            head = nextNode;
        }
        return pNode;
    }
}